package 分组;

import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;

// 注意类名必须为 Main, 不要有任何 package xxx 信息
public class Main {
    static int n, m;
    static Map<Integer, Integer> map = new HashMap<>();

    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        n = in.nextInt();
        m = in.nextInt();
        int cntmax = 0;
        for (int i = 0; i < n; i++) {
            int x = in.nextInt();
            map.put(x, map.getOrDefault(x, 0) + 1);
            cntmax = Math.max(cntmax, map.get(x));
        }
        if (map.size() > m) {
            System.out.println(-1);
        } else {
            int l = 1, r = cntmax;
            while (l < r) {
                int mid = l + r >> 1;
                if (check(mid)) {
                    r = mid;
                } else {
                    l = mid + 1;
                }
            }
            System.out.println(l);
        }
    }

    private static boolean check(int x) {
        int ret = 0;
        for (int a : map.values()) {
            ret += a / x + (a % x > 0 ? 1 : 0);
            if (ret > m) {
                return false;
            }
        }
        return true;
    }
}
